package collection_try;

import java.util.Collections;
import java.util.PriorityQueue;
import java.util.Queue;

public class PriorityQueueTest {
    public static void main(String[] args) {
        // 小顶堆：最上最小
        Queue<Integer> minPriorityQueue = new PriorityQueue<>();
        minPriorityQueue.offer(12);
        minPriorityQueue.offer(6);
        minPriorityQueue.offer(1);
        System.out.println(minPriorityQueue);
        System.out.println(minPriorityQueue.poll());
        System.out.println(minPriorityQueue.poll());
        System.out.println(minPriorityQueue.poll());

        // 大顶堆：最上最大
        Queue<Integer> maxPriorityQueue = new PriorityQueue<>(Collections.reverseOrder());
        maxPriorityQueue.add(345);
        maxPriorityQueue.add(132);
        maxPriorityQueue.add(1290);
        System.out.println(maxPriorityQueue);
        System.out.println(maxPriorityQueue.remove());
        System.out.println(maxPriorityQueue.remove());
        System.out.println(maxPriorityQueue.remove());
    }
}
